<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div class="aa"></div>
  <script>
    // function getType(val) {
    //   if(typeof val !== 'object') return typeof val
    //   let type = Object.prototype.toString.call(val)
    //   type =  type.split(' ')[1].slice(0,-1)
    //   return type.toLowerCase()
    // }
    // console.log(getType('123'))
    // console.log(getType(true))
    // console.log(getType({}))
    // console.log(getType(null))
    // console.log(getType([1,2,3]))
    // console.log(getType(document.querySelector('.aa')))

    // window.onload = function() {
    //   let div = document.querySelector('.aa')
    //   div.textContent = '123\\n\56'
    // }
    // Symbol.iterator
    // console.log(Symbol.for(123) === Symbol.for(123), Symbol('ass'))

    // Object的扩展方法
      // class Test{
      //   constructor() {
      //     this.a = 1
      //     this.b = 2
      //   }
      //   get sum() {
      //     return this.a + this.b
      //   }
      // }
      // const test = new Test()
      // console.log(test)


    const obj = {
      a: 1,
      b: 2,
      get sum() {
        return this.a+ this.b
      }
    }
    // console.log(obj)

    console.log(Object.getOwnPropertyDescriptors(obj))
    const obj2 = Object.create({}, Object.getOwnPropertyDescriptors(obj))
    // const obj2 = Object.assign({}, Object.getOwnPropertyDescriptors(obj))
    obj2.a = 3
    console.log(obj2, obj2.sum)
  </script>
</body>
</html>